<template>
    <el-dialog
        title="添加矩形"
        :visible.sync="visible"
       
        :before-close="close"
        :append-to-body="true"
       >
        <el-form ref="form">
            <el-form-item label="width">
                <el-input-number v-model="width" :min="1" ></el-input-number>
            </el-form-item>
            <el-form-item label="height">
                <el-input-number v-model="height" :min="1" ></el-input-number>
            </el-form-item>
            <el-form-item label="left">
                <el-input-number v-model="left" :min="1" ></el-input-number>
            </el-form-item>
            <el-form-item label="top">
                <el-input-number v-model="top" :min="1" ></el-input-number>
            </el-form-item>
             <el-form-item label="color">
                 <el-color-picker v-model="fill"></el-color-picker>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="close">取 消</el-button>
            <el-button type="primary" @click="comfirm">确 定</el-button>
        </span>
        </el-dialog>
</template>
<script>
export default {
    props: {
        visible: {
            type: Boolean,
            default: false
        }
    },
    data(){
        return {
            width: 100,
            height: 100,
            left: 10,
            top: 10,
            fill: '#409EFF'
        }
    },
    methods: {
        close(){
            this.$emit('close')
        },
        comfirm(){
            this.close()
          

            window.fabricCanvas.addRect({
                 width: this.width,
                height: this.height,
                left: this.left,
                top: this.top,
                fill: this.fill
            })
        },
       
    }
}
</script>
<style scoped>

</style>